package com.ls.product.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ls.product.pojo.dto.PageProductDTO;
import com.ls.product.pojo.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xiaotang
 * @since 2023-04-07
 */
@Mapper
public interface ProductMapper extends BaseMapper<Product> {

    @Update("update t_product set stock = stock - 1 where id = #{id} and stock > 0")
    int updateStock(@Param("id") Integer id);

    IPage<Product> listPageProducts(IPage<Product> page, @Param("pageProductDTO") PageProductDTO pageProductDTO);
}
